<script src="/static/js/amazeui.datatables.min.js"></script>
<script src="/static/js/dataTables.responsive.min.js"></script>
<script src="/static/js/amazeui.page.js"></script>
<script src="/static/js/layer/layer.js"></script>
<!--<script src="/static/js/app.js"></script>-->
<!--<script src="/static/js/echarts.min.js"></script>-->
<script>
    var limit = 15;
    //sendajaxdata(limit, 0);

    function sendajaxdata(limit, offset) {
        offset = limit * (offset - 1);
        var html = [];
        $.get("/costjson?limit=" + limit + "&offset=" + offset, function (data) {
            for (var i = 0; i < data.length; i++) {
                var Status = [];
                switch(parseInt(data[i].Status)){
                    case 0:
                        Status = "已提交";break;
                    case 1:
                        Status = "已审核";break;
                    case 2:
                        Status = "已完成";break;
                }

                if(i % 2 === 0){
                    html += '<tr class="gradeX">';
                } else {
                    html += '<tr class="even gradeC">';
                }
                html += '<td>'+ (i + 1) +'</td>';
                html += '<td>'+ data[i].Cost + '</td>';
                html += '<td>'+ Status +'</td>';
                html += '<td>'+ data[i].Note+'</td>';
                html += '<td>'+ data[i].Createtime+'</td>';
                html += '<td>'+ data[i].Userid+'</td>';
                html += '<td>';
                html += '<div class="tpl-table-black-operation ">';
                html += '<a href="javascript:editorCost('+ data[i].Id +');">';
                html += '<i class="am-icon-pencil"></i> 编辑 </a>';
                html += '<a href="javascript:deleteCost('+ data[i].Id +');" class="tpl-table-black-operation-del">';
                html += '<i class="am-icon-trash"></i> 删除';
                html += '</a>';
                html += '</div>';
                html += '</td>';
                html += '</tr>';
            }
            $('#costlist').html(html);
        });
    }

    function editorCost(Id){
        console.log(Id);
        $("#CostId").val(Id);
        layer.open({
            type: 2,
            title: '修改费用信息',
            maxmin: true,
            shadeClose: true, //点击遮罩关闭层
            area : ['800px' , '520px'],
            content: '/costs/cost_form'
        });
    }

    function deleteCost(Id){
        console.log(Id);
    }

    showPage(3);

</script>